import java.util.Stack;

class Solution {
    public int calculate(String s) {
        Stack<Integer> stack = new Stack<>();
        char operator = '+';
        for (int i = 0; i < s.length(); i++) {
            int tmp = 0;
            char c = s.charAt(i);
            if (c == ' ') continue;
            while (i < s.length() && c != '+' && c != '-' && c != '*' && c != '/' && c != ' ') {
                tmp *= 10;
                tmp += c - '0';
                i++;
                if (i < s.length()) {
                    c = s.charAt(i);
                }
            }
            if (operator == '+') {
                stack.push(tmp);
            }else if (operator == '-') {
                stack.push(-tmp);
            }else if (operator == '*') {
                int x = stack.pop() * tmp;
                stack.push(x);
            } else if (operator == '/') {
                int x = stack.pop() / tmp;
                stack.push(x);
            }
            operator = c;
        }
        int ret = 0;
        for (Integer n : stack) {
            ret += n;
        }
        return ret;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.calculate(" 3+5 / 2 "));
    }
}